package gao.xiaolei.dao;

import java.util.List;

import gao.xiaolei.entity.GroupManage;
import gao.xiaolei.entity.GroupManageId;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository("GroupManageDao")
public interface GroupManageDao extends JpaRepository<GroupManage, GroupManageId>{

	
	@Query(value = "select id.groupId from GroupManage where id.userId= :userId")
	public List<String> queryGroupByManage(@Param("userId") String userId);

	@Query(value = "select id.userId from GroupManage where id.groupId= :groupId")
	public String getGroupLeadingCadre(@Param("groupId") String groupId);

	@Modifying
	@Query(value = "delete from GroupManage where id.groupId= :groupId")
	public void deleteAllByGroupId(@Param("groupId") String groupId);
}
